rm(list = ls())
library(ggplot2)
library(ggthemes)
library(readxl)
library(dplyr)

dir.create("figures")
dir.create("tables")

df = read_excel("aea_nudges.xlsx", col_names = T)

df_plot = tibble(x = c("Not published", "Published Not Null", "Published Null", "WP Not Null", "WP Null"),
                 y = c(sum(df$np), sum(df$p_not_null), sum(df$p_null), sum(df$wp_not_null), sum(df$wp_null)))

df_plot %>% 
  ggplot(aes(x = x, y = y, fill = "a")) + 
  geom_bar(stat = "identity", width = .5) + 
  theme_bw() + 
  scale_fill_economist() + 
  theme(legend.position = "none", axis.text.x = element_text(angle = 45, hjust = 1)) + 
  geom_text(aes(label = y), position = position_nudge(y = 2)) + 
  labs(x = "", y = "Number of studies")
ggsave("figures/figure1.pdf", height = 4, width = 4)

